﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;

namespace csvformater
{
    class Formater
    {
        public DataTable Query(List<string> cmd,DataTable dataTable)
        {

            var tempDataTable = new DataTable();
            try
            {
                for (int i = 0; i < cmd.Count; i++)
                {
                    //fill up column name
                    var results = from row in dataTable.AsEnumerable()
                                  select row.Field<string>(cmd[i]);
                    tempDataTable.Columns[i].ColumnName = cmd[i];

                    var arrayResults = results.ToArray();
                    for (int j = 0; j < results.Count(); j++)
                    {
                        tempDataTable.Rows[j][i] = arrayResults[j];
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }



            return null;
        }
    }
}
